package com.bgs.eat.fileManager.controller;

import com.bgs.eat.fileManager.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartRequest;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/fileManager")
@CrossOrigin
public class FileController {

    @Autowired
    FileService fileService;

    /**
     * 附件上传
     * @param multipartRequest
     * @return
     */
    @PostMapping("/uploadFile")
    public Integer uploadFile(MultipartRequest multipartRequest){
        return fileService.uploadFile(multipartRequest);
    }

    /** 
     * 根据Id获取图片
     * @return
     */
    @GetMapping("/getImageById")
    public void getImageById(HttpServletResponse response,Integer id){
        fileService.getImageById(response,id);
    }



}
